package cn.zhb.backend.context;

/***
 *@Description 用于记录和获取当前线程（登录）用户id
 *@Author ZHB
 *@Create 2025/5/10 下午5:28
 **/
public class BaseContext {

    //存储用户ID
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static void setCurrentUserId(Long userId) {
        threadLocal.set(userId);
    }

    public static Long getCurrentUserId() {
        return threadLocal.get();
    }

    public static void clearCurrentUserId() {threadLocal.remove();}

}
